<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/themes/admin/assets/css/layui.css">
  </head>
  <style>
    /*分页样式*/
    .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}
    .pagination li{margin:0px 10px; border:1px solid #e6e6e6;padding: 6px 12px;display: inline-block;}
    .pagination li:hover{background:#e6e6e6 }
    .pagination .active{background-color: #dd1a20;color: #fff;}
    .pagination .disabled{color:#aaa;}
  </style>
  <body>
    <table class="layui-table">
      <colgroup>
        <col width="150">
        <col width="200">
        <col>
      </colgroup>
      <thead>
        <tr>
          <th>封面</th>
          <th>标题</th>
          <th>用户</th>
          <th>分类</th>
          <th>阅读量</th>
          <th>创建时间</th>
          <th>管理</th>
        </tr> 
      </thead>
      <tbody>
        {volist name="articleList" id="vo"}
        <tr>
          <td><img style="width:100px;height:80px" src="{$vo.img|default='/themes/blog/static/images/default/default.jpg'}" /></td>
          <td>{$vo.title}</td>
          <td>{$vo.nickname}</td>
          <td>{$vo.tagName}</td>
          <td>{$vo.read_count}</td>
          <td>{$vo.create_time|date="y年m月d日",###}</td>
          <td>
            <div class="layui-btn-group">
              <button class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon">&#xe642;</i>
              </button>
              <button onclick="delectAritcle({$vo.article_id},this)" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon">&#xe640;</i>
              </button>
            </div>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
    {$articleList->render()}
    <script src="/themes/admin/assets/layui.js"></script>
    <script src="/themes/admin/assets/jquery-3.2.1.min.js"></script>
    <script>
      layui.use('layer');              
      function delectAritcle(articleId,obj){
        layer.msg('确定删除？', {
          time: 0 //不自动关闭
          ,btn: ['删除', '取消']
          ,yes: function(index){
            $.ajax({
              type:"post",
              data:"articleId="+articleId,
              url:"/admin/article/delete",
              success:function(e){
                if(e.code == 1){
                  location.href = "/admin/article/articleList";
                  layer.msg(e.msg,{icon:1});
                }else{
                  layer.msg(e.msg);
                }
              }
            });
            layer.close(index);
          }
        });
      }
    </script>
  </body>
</html>
